<html>
<head><meta charset="utf-8"><title>PR rust-analyzer#5993 · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html">PR rust-analyzer#5993</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210219796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210219796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210219796">(Sep 16 2020 at 03:53)</a>:</h4>
<p>I'm seeking for some mentoring on <a href="https://github.com/rust-analyzer/rust-analyzer/issues/5993">rust-analyzer#5993</a> . I think there's something i need to do on lowering, but i'm not entirely sure.</p>



<a name="210239274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210239274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210239274">(Sep 16 2020 at 09:31)</a>:</h4>
<p>I think you need to modify <code>type_for_type_alias</code> in <code>hir_ty/src/lower.rs</code> to check <code>is_extern</code></p>



<a name="210239390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210239390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210239390">(Sep 16 2020 at 09:32)</a>:</h4>
<p>Because right now that will just give you a <code>TypeRef::Error</code> when the <code>= ExistingType</code> part of the alias is missing</p>



<a name="210256929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210256929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210256929">(Sep 16 2020 at 12:57)</a>:</h4>
<p>Thanks for instruction! Updated.</p>



<a name="210257898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210257898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210257898">(Sep 16 2020 at 13:05)</a>:</h4>
<p>Is it working now? Then the next step would be to add some inference tests, I think.</p>



<a name="210286452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210286452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210286452">(Sep 16 2020 at 16:25)</a>:</h4>
<p>It's not fully working, but definitely works better than without this PR. I've added a test.</p>



<a name="210286459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210286459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210286459">(Sep 16 2020 at 16:25)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="cp">#[test]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">method_resolution_foreign_opaque_type</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">check_infer</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="n">r</span><span class="err">#</span><span class="s">&quot;</span>
<span class="s">        extern &quot;</span><span class="n">C</span><span class="s">&quot; {</span>
<span class="s">            type S;</span>
<span class="s">            fn f() -&gt; &amp;&#39;static S;</span>
<span class="s">        }</span>
<span class="s">        impl S {</span>
<span class="s">            fn foo(&amp;self) -&gt; bool {</span>
<span class="s">                true</span>
<span class="s">            }</span>
<span class="s">        }</span>
<span class="s">        fn test() {</span>
<span class="s">            let s = unsafe { f() };</span>
<span class="s">            s.foo();</span>
<span class="s">        }</span>
<span class="s">        &quot;</span><span class="err">#</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="c1">// FIXME: &#39;s.foo()&#39; should be `bool`.</span>
<span class="w">        </span><span class="n">expect</span><span class="o">!</span><span class="p">[[</span><span class="n">r</span><span class="err">#</span><span class="s">&quot;</span>
<span class="s">            75..79 &#39;self&#39;: &amp;S</span>
<span class="s">            89..109 &#39;{     ...     }&#39;: bool</span>
<span class="s">            99..103 &#39;true&#39;: bool</span>
<span class="s">            123..167 &#39;{     ...o(); }&#39;: ()</span>
<span class="s">            133..134 &#39;s&#39;: &amp;S</span>
<span class="s">            137..151 &#39;unsafe { f() }&#39;: &amp;S</span>
<span class="s">            144..151 &#39;{ f() }&#39;: &amp;S</span>
<span class="s">            146..147 &#39;f&#39;: fn f() -&gt; &amp;S</span>
<span class="s">            146..149 &#39;f()&#39;: &amp;S</span>
<span class="s">            157..158 &#39;s&#39;: &amp;S</span>
<span class="s">            157..164 &#39;s.foo()&#39;: {unknown}</span>
<span class="s">        &quot;</span><span class="err">#</span><span class="p">]],</span><span class="w"></span>
<span class="w">    </span><span class="p">);</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="210286489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210286489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210286489">(Sep 16 2020 at 16:25)</a>:</h4>
<p>There's still one <code>{unknown}</code>.</p>



<a name="210286722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210286722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210286722">(Sep 16 2020 at 16:27)</a>:</h4>
<p>without this PR everything is <code>{unknown}</code>:</p>
<div class="codehilite"><pre><span></span><code>75..79 &#39;self&#39;: &amp;{unknown}
89..109 &#39;{     ...     }&#39;: bool
99..103 &#39;true&#39;: bool
123..167 &#39;{     ...o(); }&#39;: ()
133..134 &#39;s&#39;: &amp;{unknown}
137..151 &#39;unsafe { f() }&#39;: &amp;{unknown}
144..151 &#39;{ f() }&#39;: &amp;{unknown}
146..147 &#39;f&#39;: fn f() -&gt; &amp;{unknown}
146..149 &#39;f()&#39;: &amp;{unknown}
157..158 &#39;s&#39;: &amp;{unknown}
157..164 &#39;s.foo()&#39;: {unknown}
</code></pre></div>



<a name="210289597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210289597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210289597">(Sep 16 2020 at 16:51)</a>:</h4>
<p>Found the problem with method resolution, fixed it~</p>



<a name="210293527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PR%20rust-analyzer%235993/near/210293527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PR.20rust-analyzer.235993.html#210293527">(Sep 16 2020 at 17:23)</a>:</h4>
<p>Great!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>